using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using M13.Utility.Registrar;

namespace M13
{
    public class Turfs
    {
        private static Dictionary<string, Turf> _staticStringDatas = new Dictionary<string, Turf>();
        private static Dictionary<byte, Turf> _staticByteDatas = new Dictionary<byte, Turf>();
        public static Turf AirTurf { get; private set; } = TurfRegistrar<Turf>.Registered(0, "air_turf", ResourceKey.TurfMaterials.AirMat, _staticByteDatas, _staticStringDatas);
        public static Turf WaterTurf { get; private set; } = TurfRegistrar<Turf>.Registered(1, "water_turf", ResourceKey.TurfMaterials.WaterMat, _staticByteDatas, _staticStringDatas);
        public static Turf GrassTurf { get; private set; } = TurfRegistrar<Turf>.Registered(2, "grass_turf", ResourceKey.TurfMaterials.GrassMat, _staticByteDatas, _staticStringDatas);
        public static Turf StoneTurf { get; private set; } = TurfRegistrar<Turf>.Registered(3, "stone_turf", ResourceKey.TurfMaterials.StoneMat, _staticByteDatas, _staticStringDatas);
        public static Turf SnowTurf { get; private set; } = TurfRegistrar<Turf>.Registered(4, "snow_turf", ResourceKey.TurfMaterials.SnowMat, _staticByteDatas, _staticStringDatas);
        public static Turf SandTurf { get; private set; } = TurfRegistrar<Turf>.Registered(5, "sand_turf", ResourceKey.TurfMaterials.SandMat, _staticByteDatas, _staticStringDatas);
        public static Turf DioriteTurf { get; private set; } = TurfRegistrar<Turf>.Registered(6, "diorite_turf", ResourceKey.TurfMaterials.DioriteMat, _staticByteDatas, _staticStringDatas);


        public static Turf GetTurfByInt(byte id)
        {
            return _staticByteDatas.TryGetValue(id, out Turf turf) ? turf : null;
        }
        public static Turf GetTurfByString(string name)
        {
            return _staticStringDatas.TryGetValue(name, out Turf turf) ? turf : null;
        }
        public static byte GetTurfCount() { return (byte)_staticByteDatas.Count; }
    }
}